-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8337246: SpinnerSkin does not consume ENTER KeyEvent when editor ActionEvent is consumed #1523
base: master
Are you sure you want to change the base?
8337246: SpinnerSkin does not consume ENTER KeyEvent when editor ActionEvent is consumed #1523
Conversation
👋 Welcome back angorya! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@andy-goryachev-oracle has indicated that a compatibility and specification (CSR) request is needed for this pull request. @andy-goryachev-oracle please create a CSR request for issue JDK-8337246 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
Webrevs
|
I don't think that we should introduce functionality to the event system that is only accessible to controls shipped with JavaFX, but not to third-party controls. Either this is an important feature for control authors, then it should be accessible for third-party controls as well. Or it is not important, then it shouldn't be added in the first place. In my opinion, |
Does it mean you propose to make the |
This PR assumes that during dispatch events are copied using copyFor. But the documentation states that an EventDispatcher can do whatever it wants in |
If we agree that this is the right API, then yes. |
a) If the EventDispatcher does something different like creating the new events, it is up to that ED to deal with consequences. It means the developer wants to create new events and not to have the link between the events. b) I am not convinced that returning null from a dispatcher is a good solution. We already have an API for that: The bigger issue I see, as I mentioned earlier, is that
I don't think we'll ever change the event dispatching mechanism and remove the target field from Event. So the only remaining solutions are little hacks and workarounds here and there. I don't think adding return value to the dispatcher is the right solution. |
We would not be adding anything. Consuming an event is how a developer communicates to one EventDispatcher that the event was dealt with. But this information is propagated through the dispatch chain by returning null from dispatchEvent. That's all in place already. There's a variant of |
@beldenfox :
Using your own argument, a dev can write a dispatcher which returns garbage from its |
@andy-goryachev-oracle I agree that propagating the consumed flag is clearer and would lead to less surprises. Once upon a time I also thought that I could call fireEvent and then check the event's consumed flag afterward. I had to dig around a bit to figure out that all these copies were being made. It is confusing. For that matter you can't really infer that an event was consumed just because the dispatch chain returned null. The EventDispatcher documentation is a little hazy on this but in theory a dispatcher could return null for other reasons. It seems to be mostly a matter of convention that null indicates that an event was consumed. With that said in this PR changing the consumed flag in one event can change the consumed state of another event and that also seems like unexpected and surprising behavior. |
Yeah, that's why I tried to hide this from the public. I see the whole create-multiple-events idea as a bad design (tm), so the proposed change is a hack^H^H^H workaround to be used internally by FX in a few specific cases (Note1). The current PR also makes the fix localized to the specific scenario, further reducing the regression risk. I don't think this functionality should be made public, contrary to what @mstr2 and @kleopatra say (sorry!). I don't have any better ideas, and let's admit it, the current event dispatching paradigm will never be changed. Note 1: There might be more scenarios where FX needs to know whether any of the secondary events got consumed. It's unlikely that trivial use of FX triggers the issue, but we can look through the bug list to see if we have any more mentioning |
It seems much more likely that we could clean this up by explicitly specifying this behavior. Here's what I would do:
This would be sufficient to solve the problem at hand, and will also enable third-party controls to do the same. Going further, I question whether we need the |
I am afraid this makes no sense to me. I still think the root cause of the issue(s) is the cloning of events, where the cloning code ignores the possible consumption of the secondary events. I don't think we should redefine semantics of If anything, the code that clones an event for the purposes of changing its target needs to look at the isConsumed() flag and propagate it to the original event. The problem is that Looks like we've reached an impasse (again). |
Actually, no CSR is required if I revert the |
The cloning of an event is necessary in order to update the @andy-goryachev-oracle wrote:
An EventDispatcher that creates a new event without linking it to the original will break this PR. But that's a consequence you're creating. You can't say the developer is making a choice about event linking when the very notion is new with this PR. I agree with @mstr2, the dispatch machinery has an existing publicly accessible mechanism for communicating whether an event was consumed and it works fine. The documentation might be fuzzy around the edges but that can be solved. |
/csr unneeded |
@andy-goryachev-oracle determined that a CSR request is not needed for this pull request. |
Removed 'final' keyword from existing public APIs. The changes are limited to TextFieldBehavior and SpinnerSkin. |
Actually, this statement is not correct: the consumed flag will be propagated, but only if |
If a perfectly legal, properly written dispatcher in the chain creates a new event without using |
As I mentioned earlier, this is the problem of the dispatcher. Anyone can fire an event. But this PR does not link the two events generally, but addresses one specific scenario. |
You will need a CSR, because you propose to make the public |
The event is being fired which means it may pass through any number of dispatchers some of which may be written by outside developers.
There are rules for how a dispatcher works. A dispatcher that follows those rules can still break this PR. This suggests that the problem is with the PR and not the dispatcher. And there is a way to write this PR that works with the existing rules governing dispatchers. |
you are right, csr is needed. /csr |
@andy-goryachev-oracle has indicated that a compatibility and specification (CSR) request is needed for this pull request. @andy-goryachev-oracle please create a CSR request for issue JDK-8337246 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
Thanks for pointing this out. I haven't had time to look at this PR yet, but this aspect of the change is a breaking API change, and is not something we would generally do. There would need to be an extremely compelling reason to do this. I am unconvinced that there is. I haven't formed an opinion on the approach itself, since I haven't read through all of the discussion. If we do end up going this route, there are behavioral aspects that need to be captured in a CSR as well. |
Here are the rules (in EventDispatcher interface):
I don't see where it talks about creating new events, handling of cloned events and their If the dispatcher does something outside of the scope of event dispatching, it's the responsibility of the said dispatcher to deal with the consequences. I don't see how this relates to the narrow scope of this PR. |
@andy-goryachev-oracle This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
converting to Draft to investigate a solution that will not require public API changes |
/csr unneeded |
@andy-goryachev-oracle determined that a CSR request is not needed for this pull request. |
Enable backpropagation of
isConsumed
flag to the ancestor(s) of events cloned viaEvent.copyFor()
.This change has a minimal API impact and allows for a fine-grained control of when to propagate and when not to propagate.
The proposed change could make JDK-8303209 unnecessary.
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1523/head:pull/1523
$ git checkout pull/1523
Update a local copy of the PR:
$ git checkout pull/1523
$ git pull https://git.openjdk.org/jfx.git pull/1523/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1523
View PR using the GUI difftool:
$ git pr show -t 1523
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1523.diff
Webrev
Link to Webrev Comment